<?php

namespace app\common\model;

use think\Model;

class ArticleModel extends Model
{
    public $autoWriteTimestamp = true;

    protected $createTime = 'add_time';
    protected $updateTime = 'add_time';

    public static function getCate($type = null)
    {
        $lst = ['全部', '1' => '系统公告', '新闻资讯', '行业资讯', '常见问题', '关于我们'];
        return is_null($type) ? $lst : $lst[$type];
    }

    public static function news($cate = '')
    {
        return self::where('cate', $cate)->order('id', 'desc')
            ->select()->each(function ($v, $k){
                $v['image'] = cmf_get_image_url($v['image']);
            });
    }
}
